package com.example.demo.Controller;

import com.example.demo.Entity.User;
import com.example.demo.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("/list")
    public List<User> test(){
        User user=new User();
        user.setName("liuyunfeng");
        user.setPassword("123456");
        userService.Save(user);
        return userService.FindAll();
    }

    @RequestMapping("/Delete")
    void DeleteById(int id){
        userService.DeleteById(id);
    }

    @RequestMapping("/findone")
    User Find1byId(int id){
        return userService.FindById(id);
    }
}
